package com.yicong.ants.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.flyco.tablayout.SlidingTabLayout;
import com.yicong.ants.R;

/**
 * @author cchao
 * @version 2019-07-31.
 */
public class SlidingTabLayout2 extends SlidingTabLayout {
    int mPreTab = 0;

    public SlidingTabLayout2(Context context) {
        super(context);
    }

    public SlidingTabLayout2(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public SlidingTabLayout2(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    public void onPageSelected(int position) {
        super.onPageSelected(position);
        LinearLayout tabContainer = (LinearLayout) getChildAt(0);
        mPreTab = getCurrentTab();
        for (int i = 0; i < tabContainer.getChildCount(); ++i) {
            View tabView = tabContainer.getChildAt(i);
            final boolean isSelect = i == position;
            TextView tab_title = tabView.findViewById(R.id.tv_tab_title);

            if (tab_title != null) {
                tab_title.setTextSize(isSelect ? 18 : 16);
            }
        }
    }
}
